/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jsrpc.core;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;

/**
 *
 * @author neo
 */
public class ListHandler extends ObjectHandler {

    @Override
    public Object parseObject(ParserObject parser, Hashtable table, Properties prop) {
//        for (Enumeration enums = table.keys(); enums.hasMoreElements();) {
//            String key = (String) enums.nextElement();
//            System.out.println("key[" + key + "]value[" + (String) table.get(key) + "]");
//
//        }
        //String casting = (String)table.get(Key.CASTING_CLASS);
        String sszie = (String)table.get(Key.LIST_SIZE);
        List list = new ArrayList();
        DefaultObjectHandler handle = new DefaultObjectHandler();
        int size = Integer.parseInt(sszie);
        for (int i = 0; i < size; i++) {
            String src = (String)table.get("list_"+i);
            String s[] = parser.parser(src, ",");
            Hashtable nTable = parser.getTable(s);
            Object obj = handle.parseObject(parser, nTable, prop);
            list.add(obj);
        }
        return list;
    }
}
